<?php

namespace App\Http\Controllers\Personal;

use App\Model\Staff;
use App\Model\Users;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class IndexController extends Controller
{

	protected $users;
	protected $staff;
	public function __construct()
	{
		$this->users=new Users();
		$this->staff=new Staff();

	}
	//
	//	个人端手机号注册
	public function register(Request $request){

		$data['phone']=$request->phone;
		DB::beginTransaction();
		try{
			$result=$this->users->create($data);
			$staff['uid']=$result['id'];
			$staff['phone']=$result['phone'];
			$result2=$this->staff->create($staff);
			DB::commit();
		}catch (\Exception $exception){
			$message=$exception->getMessage();
			DB::rollBack();
		}
		if(!isset($message)){
			return $this->success($result);
		}else{
			return $this->failed($message);
		}
	}



}
